#!/usr/bin/env python

# arc.py

from __future__ import division

import math
import sys

from ot_simulator.template.template_funs import frange

def arc(angle, inc=1.0, radius=1.0):
    r'''Yields x, y values from -90 - angle/2 to -90 + angle/2.
    '''

    for a in frange(inc, -90 - angle/2, -90 + angle/2):
        a_radians = math.radians(a)
        c, s = math.cos(a_radians), math.sin(a_radians)
        yield radius * c, radius * s 

def run(filename, angle, inc=1.0, radius=1.0):
    with open(filename, 'wt') as f:
        for x, y in arc(angle, inc, radius):
            print >> f, "{0},{1}".format(x, y)

if __name__ == "__main__":
    if len(sys.argv) != 3:
        print >> sys.stderr, "usage: {0} fileout.csv angle".format(sys.argv[0])
        sys.exit(2)
    run(sys.argv[1], float(sys.argv[2]))
